// pages/login/login.js
var app = getApp()
Page({

  /**
   * 页面的初始数据
   */
  data: {
    bghei:app.globalData.winheight/6,
    bg2hei:app.globalData.winheight/1.1,
    boxhei:app.globalData.winheight/1.1/1.5,
    pubed:true,
    tip1:'',
    liebiao:[]
  },
  zhuye(){
    wx.navigateTo({
      url: '../ayeshou/yeshou',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this
    var lieaaa = [
    {"headpic":"https://www.juquduo.com/static/resourse/login/头像.png","ActivityName":"13454334","time":1593786895000},
    {"headpic":"https://www.juquduo.com/static/resourse/yeshou/地图1.jpg","ActivityName":"63454334","time":1599780895000}]

    var newlie = [];
    var date = new Date()
    for (var i = 0; i < lieaaa.length; i++) {
      var picname = lieaaa[i].headpic
      var ActivityName = lieaaa[i].ActivityName
      var date = new Date(lieaaa[i].time)
      var time =  date.toLocaleString()
      var item = { picname: picname, ActivityName: ActivityName, time: time };
      newlie = newlie.concat(item);
    }
    console.log(newlie)
    that.setData({
      liebiao: newlie
    })

    wx.setNavigationBarTitle({
        title: '活动商',
      })
      console.log(this.data.liebiao)
      wx.request({
        url: 'https://www.juquduo.com/juquduo/activity/company/show_activity',
        success(res){
          console.log(res)
          var newliea = []
          var date = new Date()
          for (var i = 0; i < res.data.length; i++) {
            var picname = res.data[i].Avatar
            var ActivityName = res.data[i].ActivityName
            var date = new Date(res.data[i].Created*1000)
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = date.getDate() + ' ';
            var h = date.getHours() + ':';
            var m = (date.getMinutes()+1 < 10 ? '0'+(date.getMinutes()) : date.getMinutes());
            console.log(Y+M+D+h+m);
           var time =  Y+M+D+h+m
            // var time =  date.toLocaleString()
            var item = { picname: picname, ActivityName: ActivityName, time: time };
            newliea = newliea.concat(item);
          }
          console.log(res)
          // return newlie
          // if(newliea[0].picname){
            that.setData({
              liebiao: newliea
              
            })
          // }
        }
      })
  },
  // 区分公司和玩家
  gsload(){
    this.setData({pubed:true})
  },
  wjload(){
    this.setData({pubed:false})
  },
  deallist(lieaaa){
    var newlie = []
    var date = new Date()
    for (var i = 0; i < lieaaa.length; i++) {
      var picname = lieaaa[i].Avatar
      var ActivityName = lieaaa[i].ActivityName
      var date = new Date(lieaaa[i].Created*1000)
      var time =  date.toLocaleString()
      var item = { picname: picname, ActivityName: ActivityName, time: time };
      newlie = newlie.concat(item);
    }
    return newlie
  },

  createbtn(){
    // 跳到选点界面
    wx.redirectTo({
      url: '../comnewar/bchoopoi',
    })
  }


})